import type { BytemdPlugin } from 'bytemd';
const codeCopyPlugin = (): BytemdPlugin => {
  const createCopyDom = (text: any): HTMLElement => {
    const copyDom = document.createElement('div');
    copyDom.className =
      'icon-[ph--copy-bold] absolute right-2 top-2 cursor-pointer';
    copyDom.addEventListener('click', () => {
      // copyToClipboard(text);
      // message.info({
      // 	title: "系统通知",
      // 	content: "复制成功",
      // });
    });
    return copyDom;
  };
  return {
    viewerEffect: ({ markdownBody }) => {
      // 获取所有code标签
      const els = markdownBody.querySelectorAll('pre>code');
      if (els.length === 0) return;
      // 往pre标签中append copy节点
      // els.forEach((itm: HTMLElement) => {
      // 	itm.parentNode.appendChild(createCopyDom(itm.innerText));
      // });
    },
  };
};
